view from close

funny meems

--

// Java program to create a simple console-based application// This program demonstrates basic user interaction and functionalityimport java.util.Scanner;public class FunnyMemesApp { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); boolean running = true; System.out.println("\nWelcome to the Funny Memes App!"); System.out.println("Your daily dose of humor awaits.\n"); while (running) { System.out.println("What would you like to do?\n"); System.out.println("1. View a random meme"); System.out.println("2. Add your own meme"); System.out.println("3. Exit\n"); System.out.print("Enter your choice (1/2/3): "); int choice = scanner.nextInt(); scanner.nextLine(); // Consume newline character switch (choice) { case 1: displayRandomMeme(); break; case 2: System.out.print("Enter your funny meme text: "); String meme = scanner.nextLine(); addMeme(meme); break; case 3: System.out.println("Thank you for using the Funny Memes App. Goodbye!"); running = false; break; default: System.out.println("Invalid choice. Please try again.\n"); } } scanner.close(); } private static void displayRandomMeme() { String[] memes = { "Why don't skeletons fight each other? They don't have the guts!", "I told my wife she should embrace her mistakes. She gave me a hug.", "Why don’t scientists trust atoms? Because they make up everything!", "I’m reading a book on anti-gravity. It’s impossible to put down!" }; int randomIndex = (int) (Math.random() * memes.length); System.out.println("\nHere's your random meme: \n" + memes[randomIndex] + "\n"); } private static void addMeme(String meme) { // For now, we'll just acknowledge the meme // In a real application, you might save this to a database or file System.out.println("\nThank you! Your meme has been added: \n" + meme + "\n"); }}
Muhammad Jawad
Nessun risultato di ricerca